Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support prepared statement placeholder arg ? and $ #420

Merged
merged 1 commit into from
Feb 17, 2022

Conversation

gamife
Copy link
Contributor

@gamife gamife commented Feb 11, 2022

#145 support ? or $foo prepared statement arg placeholder.

SELECT * FROM student WHERE id = ?;
SELECT * FROM student WHERE id = $Id1;

@coveralls
Copy link

coveralls commented Feb 11, 2022

Pull Request Test Coverage Report for Build 1827316036

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 24 of 27 (88.89%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.006%) to 90.588%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/parser.rs 3 4 75.0%
src/tokenizer.rs 6 8 75.0%
Totals Coverage Status
Change from base Build 1818592432: -0.006%
Covered Lines: 7074
Relevant Lines: 7809

💛 - Coveralls

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks (again) for the contribution @gamife

@@ -59,6 +59,8 @@ pub enum Value {
},
/// `NULL` value
Null,
/// `?` or `$` Prepared statement arg placeholder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not familiar with the $ syntax for prepared argument placeholders. What database system do they come from?

I have only ever seen ? used for prepared statement placeholders

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is an example from pgsql's document.

PREPARE fooplan (int, text, bool, numeric) AS
    INSERT INTO foo VALUES($1, $2, $3, $4);
EXECUTE fooplan(1, 'Hunter Valley', 't', 200.00);

However, only numbers follow the $.
Then I found that there was a need for $foo in the issue. #145 (comment)

So the final product is this:

SELECT * FROM student WHERE id = $Id1;

Maybe there can't be a separate $placeholder here.

Thank you even more for your continued contribution. I'm just a spoon of water in the ocean :-)

@alamb alamb changed the title feat: add arg placeholder Add prepared statement placeholder arg ? Feb 16, 2022
@alamb alamb changed the title Add prepared statement placeholder arg ? Support prepared statement placeholder arg ? Feb 16, 2022
@alamb alamb changed the title Support prepared statement placeholder arg ? Support prepared statement placeholder arg ? and $ Feb 17, 2022
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thanks @gamife

@alamb alamb merged commit 899f91b into apache:main Feb 17, 2022
ovr pushed a commit to cube-js/sqlparser-rs that referenced this pull request Mar 28, 2022
ovr pushed a commit to cube-js/sqlparser-rs that referenced this pull request Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants